How to install in cpanel?
Requirements
- PHP 7.2+
- Node 12+
- Mysql 5+
Folder Structure
Go to cPanel-project from the package folder.
You will get the following files.
- db.sql
- Frontend
- Backend
Database
- Log in to your cPanel account.
- Scroll down to the "Databases" section and click on "MySQL Databases".
- Under "Create New Database", enter a name for your database.
- Click the "Create Database" button.
- Scroll down to "Add New User" and enter a username and password for the database.
- Click the "Create User" button.
- Scroll down to "Add User to Database" and select the newly created user and database from the drop-down menus.
- Click the "Add" button.
- In the next step, you can set the permissions for the user by selecting the appropriate checkboxes.
- Click the "Make Changes" button to complete the process.
Your database is now created and a user is assigned to it, and you can now use it in the backend.
Now it's time to import the database.
Import database
- Log in to your cPanel account.
- Scroll down to the "Databases" section and click on "phpMyAdmin".
- You will be redirected to a new page
- Click on "Import".
- Click on "Choose file" and uploaddb.sql (Which will be found in) cPanel-project > db.sql.
Now it's time to put the database credentials in the backend configuration file
Database configuration
- Open the cPanel-project > Backend > .env file
- Find and change the DB_DATABASE, DB_USERNAME and DB_PASSWORD
- DB_DATABASE: Name of your database
- DB_USERNAME: Name of the username of the database
- DB_PASSWORD: Password of the database
We've attached a video also.
Backend configuration
First step to configure the backend configuration is to set up the APP_URL and CLIENT_BASE_URL.
- Open cPanel-project > Backend > .env
- Update the value of APP_URL and CLIENT_BASE_URL
- APP_URL: Root URL of your admin panel. eg. http://admin.yourdomain.com
- CLIENT_BASE_URL: URL of your frontend. eg. http://www.yourdomain.com
Backend deployment
You will be needing a subdomain for the admin panel.
- Log in to your cPanel account.
- Scroll down to the "Domains" section and click on "Domains".
- Click on Create a new domain.
- Fill up the domain name and Root directory.
- Create the subdomain.
Now it's time to upload the backend project to the server.
Upload to server
- Create a zip file from cPanel-project > Backend
- Upload the zip and unzip it to the Root directory of your created subdomain.
- Please edit the subdomain data by going to the cPanel and go to Domains > Manage.
- Now update the Root directory of the subdomain by set it to the public folder of that uploaded backend.
Now it's time to give Write permission to some folders and subfolders.
Write permission
- Go to the root of the admin panel in the server.
- Find the storage folder and right click on the folder.
- Click on Change permissions folder and right click on the folder.
- Check all the checkbox and Save.
- Repeat the process to the folders below also.
- public > uploads
- storage
- bootstrap
- Repeat the process for all the subfolders also.
It's time to clear the cache of the backend by going to admin.yourdomain.com/api/clear-cache.
You can browse the admin panel now.
Use these credentials below to login to the admin panel.
- Admin email: admin@mail.com
- Admin password: 123456
We've attached a video also.
Frontend configuration
First step to configure the backend configuration is to set up the siteName siteUrl and apiBase.
- Go to the cPanel-project > Frontendfolder in your computer
- Edit the config.json file
- Change the siteName siteUrl and apiBase form config.json file
- siteName: Name your project
- siteUrl: Domain of your site. eg. yourdomain.com
- apiBase: Root Url of your admin panel. eg. http://www.yourdomain.com/ Please don't forget to add / at the end of the URL
Frontend deployment
We are going to install the frontend in a subdomain.
- Log in to your cPanel account.
- Scroll down to the "Domains" section and click on "Domains".
- Click on Create a new domain.
- Fill up the domain name and Root directory.
- Create the subdomain.
It's time to create a node js app
Node js app creation
- Log in to your cPanel account.
- Scroll down to the "Software" section and click on "Set up node.js app".
- Click on Create Application.
- Create a node.js app by fill up these values.
- Application root: Root location of the subdomain you have created
- Application URL: subdomain you have created
- Application startup file: app.js
Now it's time to build the front end locally and upload it to the server.
Building the frontend
- Go to the cPanel-project > Frontendfolder in your computer
- Edit the package.json file
- Update the value of hostname from scripts > build
- Now open the command prompt in the folder
- Now run npm run build
- You have to have node js installed in your computer
- Make sure the version of node is same for your local machine and server machine
- To check the version of node js, please run this command in the command prompt
- Now compress the whole front end and upload it to the Application root
- Unzip the file
You can browse the website now.
We've attached a video also.